package com.mycompany.myapp.service.mapper;

import com.mycompany.myapp.domain.*;
import com.mycompany.myapp.service.dto.CommodityDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity {@link Commodity} and its DTO {@link CommodityDTO}.
 */
@Mapper(componentModel = "spring", uses = {})
public interface CommodityMapper extends EntityMapper<CommodityDTO, Commodity> {


    @Mapping(target = "comments", ignore = true)
    @Mapping(target = "removeComment", ignore = true)
    @Mapping(target = "collections", ignore = true)
    @Mapping(target = "removeCollection", ignore = true)
    @Mapping(target = "cartItems", ignore = true)
    @Mapping(target = "removeCartItem", ignore = true)
    @Mapping(target = "orderItems", ignore = true)
    @Mapping(target = "removeOrderItem", ignore = true)
    Commodity toEntity(CommodityDTO commodityDTO);

    default Commodity fromId(Long id) {
        if (id == null) {
            return null;
        }
        Commodity commodity = new Commodity();
        commodity.setId(id);
        return commodity;
    }
}
